#ifndef CAR_MAINTENANCE_CSV_STRUCT_HH
#define CAR_MAINTENANCE_CSV_STRUCT_HH 1


#include <string>
#include <iostream>
#include <vector>
#include "otl8.hpp"

#include "datetime_period.hpp"

static const char*  car_maintenance_struct_s = "SELECT MAINTENANCEID, MAINTENANCEDATE, TOTALAMOUNT, PLATEID, NOTES FROM CAR_MAINTENANCE_STRUCT";

static const char*  car_maintenance_struct_i = "INSERT INTO CAR_MAINTENANCE_STRUCT ( MAINTENANCEID, MAINTENANCEDATE, TOTALAMOUNT, PLATEID, NOTES )VALUES(:f1<int>, :f2<date>, :f3<double>, :f4<int>, :f5<char[128]>)";

static const char* car_maintenance_struct_c = "CREATE TABLE CAR_MAINTENANCE_STRUCT ( MAINTENANCEID INTEGER , MAINTENANCEDATE  , TOTALAMOUNT FLOAT , PLATEID INTEGER , NOTES VARCHAR(128) )";
class car_maintenance_struct
{



public:
car_maintenance_struct():_maintenanceId(0), _maintenanceDate(boost::gregorian::not_a_date_time), _totalAmount(0), _plateId(0), _notes(""){_select=car_maintenance_struct_s;_insert=car_maintenance_struct_i;_create=car_maintenance_struct_c;}


car_maintenance_struct(int a__maintenanceId, boost::gregorian::date a__maintenanceDate, double a__totalAmount, int a__plateId, std::string a__notes):_maintenanceId(a__maintenanceId) , _maintenanceDate(a__maintenanceDate) , _totalAmount(a__totalAmount) , _plateId(a__plateId) , _notes(a__notes) {_select=car_maintenance_struct_s;_insert=car_maintenance_struct_i;_create=car_maintenance_struct_c;}


int maintenanceId(){return  _maintenanceId;}
void set_maintenanceId(int a__maintenanceId){ _maintenanceId = a__maintenanceId;}


boost::gregorian::date maintenanceDate(){return  _maintenanceDate;}
void set_maintenanceDate(boost::gregorian::date a__maintenanceDate){ _maintenanceDate = a__maintenanceDate;}


double totalAmount(){return  _totalAmount;}
void set_totalAmount(double a__totalAmount){ _totalAmount = a__totalAmount;}


int plateId(){return  _plateId;}
void set_plateId(int a__plateId){ _plateId = a__plateId;}


std::string notes(){return  _notes;}
void set_notes(std::string a__notes){ _notes = a__notes;}


car_maintenance_struct & operator=( const car_maintenance_struct & x)
{
	_maintenanceId =  x._maintenanceId;
	_maintenanceDate =  x._maintenanceDate;
	_totalAmount =  x._totalAmount;
	_plateId =  x._plateId;
	_notes =  x._notes;
	return *this;
}


bool operator==( const car_maintenance_struct & x)
{
	return 	_maintenanceId ==  x._maintenanceId &&
	_maintenanceDate ==  x._maintenanceDate &&
	_totalAmount ==  x._totalAmount &&
	_plateId ==  x._plateId &&
	_notes ==  x._notes;
}


friend std::istream& operator >> (std::istream& ist, car_maintenance_struct & t)
{
	if (!(ist >> t._maintenanceId)) return ist;
	if (!(ist >> t._maintenanceDate)) return ist;
	if (!(ist >> t._totalAmount)) return ist;
	if (!(ist >> t._plateId)) return ist;
	if (!(ist >> t._notes)) return ist;

	return ist;
}

friend std::ostream& operator << (std::ostream& ost, car_maintenance_struct & t)
{
	ost << t._maintenanceId << " ";
	ost << t._maintenanceDate << " ";
	ost << t._totalAmount << " ";
	ost << t._plateId << " ";
	ost << t._notes << " ";

	return ost;
}

/*
friend otl_stream& operator >> (otl_stream& ist, car_maintenance_struct & t)
{
	ist >> t._maintenanceId;
	ist >> t._maintenanceDate;
	ist >> t._totalAmount;
	ist >> t._plateId;
	ist >> t.buf; t._notes=(const char*)t.buf;

	return ist;
}

friend otl_stream& operator << (otl_stream& ost, car_maintenance_struct & t)
{
	ost << t._maintenanceId ;
	ost << t._maintenanceDate ;
	ost << t._totalAmount ;
	ost << t._plateId ;
	ost << t._notes.c_str() ;

	return ost;
}
*/

std::string select_stmt() { return _select; }
std::string insert_stmt() { return _insert; }
std::string create_stmt() { return _create; }


private:

	int	_maintenanceId;
	boost::gregorian::date	_maintenanceDate;
	double	_totalAmount;
	int	_plateId;
	std::string	_notes;
	std::string _create;
	std::string _select;
	std::string _insert;
char buf[128];
};
#endif
